<?php
// +----------------------------------------------------------------------
// | RXThinkCMF_EVTP5.1_PRO前后端分离旗舰版框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2018~2021 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | 作者: ZhangXuanNeng <rxthinkcmf@163.com>
// +----------------------------------------------------------------------
// | 免责声明:
// | 本软件框架禁止任何单位和个人用于任何违法、侵害他人合法利益等恶意的行为，禁止用于任何违
// | 反我国法律法规的一切平台研发，任何单位和个人使用本软件框架用于产品研发而产生的任何意外
// | 、疏忽、合约毁坏、诽谤、版权或知识产权侵犯及其造成的损失 (包括但不限于直接、间接、附带
// | 或衍生的损失等)，本团队不承担任何法律责任。本软件框架只能用于公司和个人内部的法律所允
// | 许的合法合规的软件产品研发，详细声明内容请阅读《框架免责声明》附件；
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\service\MemberAuthService;
use app\admin\service\MemberInfoService;
use app\admin\service\MemberService;
use app\admin\service\UserAuthService;
use app\common\controller\Export;
use app\qsapi\model\BoxMemberInfo;

/**
 * 盒子用户管理
 * @author ZhangXuanNeng
 * @since 2020/11/20
 * Class Member
 * @package app\admin\controller
 */
class MemberInfo extends Backend
{
    /**
     * 初始化
     * @author ZhangXuanNeng
     * @since 2020/11/20
     */
    protected function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->service = new MemberInfoService();
    }

    public function index(){
        $result = $this->service->getList();
        return $this->jsonReturn($result);
    }

    /**
     * 修改/新增
     */
    public function editRole(){
        $result = $this->service->editRole();
        return $this->jsonReturn($result);
    }

    public function export(){
        $param       = request()->param();
        $map         = [];
        $id          = $param['id'] ?? "";
        $phone       = $param['phone'] ?? "";
        $platform    = $param['platform'] ?? "";
        $status      = $param['status'] ?? "";
        $nickname    = $param['nickname'] ?? "";
        $order       = $param['order'] ?? "";
        $sort        = $param['sort'] ?? "";
        $create_time = $param['create_time'] ?? "";
        //  `log_off` tinyint(3) NOT NULL DEFAULT '0' COMMENT '0未注销。  1，申请注销。 2，已注销.',
        //  `age_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '实名认证状态:0=未实名,1=成年,2=未成年',
        if ($id) {
            $map[] = ['a.id', '=', $id];
        }
        if ($phone) {
            $map[] = ['a.phone', '=', $phone];
        }
        if ($nickname) {
            $map[] = ['a.nickname', '=', $nickname];
        }
        if (!empty($create_time)) {
            $map[] = ['a.create_time', 'between', [strtotime($create_time[0]), strtotime($create_time[1])]];
        }

        switch ($status) {
            case 0:
                $map[] = ['a.log_off', '=', 0];
                break;
            case 1:
                $map[] = ['a.log_off', '=', 1];
                break;
            case 2:
                $map[] = ['a.age_status', 'between', [1, 2]];
                break;
            case 3:
                $map[] = ['a.age_status', '=', 0];
                break;
        }

        if ($platform) {
            $map[] = ['l.platform', '=', $platform];
        }
        $Export = new Export();
        $Export->BoxMemberInfoExport($map);
    }
}
